package cn.wei.sdd.core.controller.admin;


import cn.wei.common.result.R;
import cn.wei.sdd.base.util.JwtUtils;
import cn.wei.sdd.core.pojo.query.CheckRecordQuery;
import cn.wei.sdd.core.pojo.vo.AdminCheckOneVO;
import cn.wei.sdd.core.pojo.vo.CheckOrdersVO;
import cn.wei.sdd.core.service.CheckRecordService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 验收记录表 前端控制器
 * </p>
 *
 * @author Wei
 * @since 2021-11-03
 */
@RestController
@Api(tags = "验收记录管理")
@RequestMapping("/admin/core/checkRecord")
public class AdminCheckRecordController {

    @Resource
    private CheckRecordService checkRecordService;


    @ApiOperation("验收记录列表")
    @GetMapping("checkRecordList/{page}/{limit}")
    public R getCheckRecordList(
            @ApiParam(value = "当前页码",required = true)
            @PathVariable("page") Long page,
            @ApiParam(value = "页码记录数",required = true)
            @PathVariable("limit") Long limit,
            @ApiParam(value = "搜索对象",required = false)
                    CheckRecordQuery checkRecordQuery

            ){
        Page<CheckOrdersVO> pageParam = new Page(page, limit);
        IPage<CheckOrdersVO> pageModel = checkRecordService.listPage(pageParam,checkRecordQuery);
        return R.ok().data("pageModel",pageModel);
    }

    @ApiOperation("验收订单")
    @PostMapping("checkOne")
    public R check(
            @RequestBody AdminCheckOneVO adminCheckOneVO,
            HttpServletRequest request){
        String token = request.getHeader("token");
        Long userId = JwtUtils.getUserId(token);
        checkRecordService.check(adminCheckOneVO,userId);
        return R.ok().message("确定成功");
    }



}

